<?php

namespace app\common\model;

use think\Model;

class Article extends Model
{
    protected $table = 'article';

    public function getAllData($where,$get)
    {

        $data = $this->db($this->table)
            ->alias('a')
            ->join('category c', 'c.cate_id=a.cate_id')
            ->field('a.*,c.cate_name')
            ->where('a.is_recycle',1)
            ->where('a.is_draft',1)
            ->where($where)
            ->order('a.update_time desc')
            ->paginate(15,false,['query'=>$get]);
        return $data;
    }

    public function getAllrecycle($where,$get){
        $data = $this->db($this->table)
            ->alias('a')
            ->join('category c', 'c.cate_id=a.cate_id')
            ->field('a.*,c.cate_name')
            ->where('a.is_recycle',0)
            ->where($where)
            ->order('a.update_time desc')
            ->paginate(15,false,['query'=>$get]);
        return $data;
    }

    public function getAlldraft($where,$get){
        $data = $this->db($this->table)
            ->alias('a')
            ->join('category c', 'c.cate_id=a.cate_id')
            ->field('a.*,c.cate_name')
            ->where('a.is_draft',0)
            ->where($where)
            ->order('a.update_time desc')
            ->paginate(15,false,['query'=>$get]);
        return $data;
    }
}
